﻿using System;
using System.Collections.Generic;
using System.Linq;
using DotNETStack.Core.Data;
using DotNETStack.Core.Model;

namespace DotNETStack.LinqToSqlDataProvider.Data
{
    public class QuestionRepository : IQuestionRepository
    {
        #region Private Properties

        private DotNETStackDbDataContext Context { get; set; }

        #endregion

        #region Constructors

        public QuestionRepository(DotNETStackDbDataContext context)
        {
            Context = context;
        }

        #endregion

        #region Public Methods

        public IQuestion GetById(Int32 id)
        {
            return Context.dns_Questions.WithId(id).SingleOrDefault();
        }

        public List<IQuestion> GetAll(Int32 PageIndex, Int32 PageSize)
        {
            return Context.dns_Questions.Paged(PageIndex, PageSize).Cast<IQuestion>().ToList();
        }

        #endregion
    }
}